package com.study.lihan.letcode;

import java.util.HashSet;

/**
 * @Author: lihan
 * @Date : 2022/9/5- 09
 * @DESCRIPTION: 125. 验证回文串
 *
 * @version: 1.0
 */
public class My125 {
    public static void main(String[] args) {
        char temp = 'a';
        int b = temp;
        System.out.println(isPalindrome("0P"));


    }
/**
 两个指针从头到尾遍历,如何确实是数字或者是字符串
 **/
    public static boolean isPalindrome(String s) {
        if (s== null)return false;

        s = s.toLowerCase();
        char[] chars = s.toCharArray();
        int first = 0;
        int last = chars.length-1;
        while (first < last){
            if (!Character.isLetterOrDigit(chars[first])){
                first++;
                continue;
            }
            if (!Character.isLetterOrDigit(chars[last])){
                last--;
                continue;
            }
            if (chars[first] != chars[last]){
                return  false;
            }
            first++;
            last--;
        }

        return true;
    }

}
